package com.lemeshko.SimpleWebApp.listeners;

import java.util.HashMap;
import java.util.Map;

import javax.servlet.ServletContext;
import javax.servlet.ServletContextEvent;
import javax.servlet.ServletContextListener;
import javax.servlet.annotation.WebListener;

/**
 * Application Lifecycle Listener implementation class ContextListener
 *
 */
@WebListener
public class ContextListener implements ServletContextListener {

	private Map<String, String> usersMap;
	private ServletContext context = null;
	
    
    public void contextInitialized(ServletContextEvent event) {
    	
    	context = event.getServletContext();
    	usersMap = new HashMap<String, String>();
    	context.setAttribute("usersMap", usersMap);
    }
    
    public void contextDestroyed(ServletContextEvent event) {
    	context.removeAttribute("userMap");
    }
}
